<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>穿梭框组件</title>
    <link href="../../resources/js/plugins/layui/css/layui.css" type="text/css" rel="stylesheet"  />
    <script type="text/javascript" src="../../resources/js/plugins/layui/layui.js"></script>
    <script type="text/javascript" src="../../resources/js/actions.js"></script>
    <style>

        .layui-table-tool{
            line-height: 50px;
            background: #EEF1F8;
            padding: 0px;
            color: #000000;
        }

        .layui-table-tool-temp{
            padding-right: 10px;
        }

        .layui-table-cell .layui-form-checkbox[lay-skin=primary] {
            top: 0px;
        }
    </style>
</head>
<body>
<div class="layui-container" style="margin-top: 15px;">


    <div id="flowsTransfer"></div>
    <div class="layui-row" style="text-align: center;margin-top:20px">
        <div  >
            <button class="layui-btn blue-btn" id="btn_save" style="background-color: #1E85EC;color: #fff;">保存</button>
            <button class="layui-btn blue-btn" id="btn_canel" style="margin-left: 10px;background-color: #1E85EC;color: #fff;">取消</button>
        </div>
    </div>
    <div id="root1"></div>
</div>
</body>

<script>
/*    var dataS = [{'fid':'1','fname':'笔试','nickname':'笔试','display':'是','state':'0'}
                ,{'fid':'2','fname':'资料审核','nickname':'资料审核','display':'是','state':'0'}
                ,{'fid':'3','fname':'面试','nickname':'面试','display':'否','state':'0'}
                ,{'fid':'6','fname':'背景调查','nickname':'背景调查','display':'是','state':'0'}
                ,{'fid':'4','fname':'实作','nickname':'实作','display':'是','state':'0'}
                ,{'fid':'5','fname':'体检','nickname':'体检','display':'是','state':'0'}
                ,{'fid':'9','fname':'签约','nickname':'签约','display':'是','state':'0'}
                ,{'fid':'7','fname':'实习','nickname':'实习','display':'是','state':'0'}];*/

    var recruittypeVal = GetQueryString('recruittype');
    var reDataGs = [{'fid':'0','fname':'简历筛选','nickname':'简历筛选','display':'是','state':'0'}
                    ,{'fid':'1','fname':'素质','nickname':'素质','display':'是','state':'0'}
                    ,{'fid':'2','fname':'笔试','nickname':'笔试','display':'是','state':'0'}
                    ,{'fid':'3','fname':'资料审核','nickname':'资料审核','display':'是','state':'0'}
                    ,{'fid':'4','fname':'面试','nickname':'面试','display':'否','state':'0'}
                    ,{'fid':'5','fname':'背景调查','nickname':'背景调查','display':'是','state':'0'}
                    ,{'fid':'7','fname':'体检','nickname':'体检','display':'是','state':'0'}
                    ,{'fid':'9','fname':'录用','nickname':'体检','display':'是','state':'0'}];

    var reDataZz = [{'fid':'0','fname':'毕业生推荐','nickname':'简历筛选','display':'是','state':'0'}
                    ,{'fid':'1','fname':'素质','nickname':'素质','display':'是','state':'0'}
                    ,{'fid':'2','fname':'笔试','nickname':'笔试','display':'是','state':'0'}
                    ,{'fid':'3','fname':'资料审核','nickname':'资料审核','display':'是','state':'0'}
                    ,{'fid':'4','fname':'面试','nickname':'面试','display':'否','state':'0'}
                    ,{'fid':'5','fname':'背景调查','nickname':'背景调查','display':'是','state':'0'}
                    ,{'fid':'7','fname':'体检','nickname':'体检','display':'是','state':'0'}
                    ,{'fid':'9','fname':'录用','nickname':'体检','display':'是','state':'0'}];

    layui.config({
        base: '../../resources/js/plugins/layui_exts/transfer/'
    }).use(['transfer'],function () {
        var transfer = layui.transfer,$ = layui.$;
        var index = parent.layer.getFrameIndex(window.name);
        //数据源
       var data1 = reDataGs;
      var data2 = [];
        //表格列
        var cols = [{type: 'checkbox', fixed: 'left'}
            , {field: 'fid', title: 'fid', width: 80, sort: false, hide: true}
            , {field: 'fname', title: '流程名称', minWidth: 120,}
            , {field: 'nickname', title: '流程别名', width: 80, hide: true}
            , {field: 'webname', title: '前端显示名称', width: 80, hide: true}
            , {field: 'state', title: '流程状态', width: 80, hide: true}
            , {field: 'display', title: 'display', width: 80, hide: true},]
        //表格配置文件
        var tabConfig = {'page':false,'limits':[10,50,100],'height':400}
        var tb1 = transfer.render({
            elem: "#flowsTransfer" //指定元素
            ,data: data1
            ,id:"flowsTransferCh"
            ,parseData: function(res){
                return {
                    "value": res.fid //数据值
                    ,"title": res.fname //数据标题
                    ,"disabled": res.disabled  //是否禁用
                    ,"checked": res.checked //是否选中
                }
            }
           // cols: cols, //表格列  支持layui数据表格所有配置
            //url: 'test/datas/flows.json',
           // data: [data1,data2], //[左表数据,右表数据[非必填]]
           // tabConfig: tabConfig //表格配置项 支持layui数据表格所有配置
        })
        //transfer.get(参数1:初始化返回值,参数2:获取数据[all,left,right,l,r],参数:指定数据字段)

        //获取数据
        $('#btn_save').on('click',function () {
         //   var data = transfer.get(tb1,'r');
            var data = transfer.getData('flowsTransferCh'); //获得右侧数据
           // layer.msg(JSON.stringify(data))
            var tabledatas= parent.layui.table.cache['flowsTable'];
            if(data.length>0){
                var reArr=[];
                for(var i=0;i<data.length;i++){
                    for(var j=0;j<data1.length;j++){
                        if(data1[j].fid === data[i].value){
                            reArr.push(data1[j]);
                            break;
                        }
                    }
                }
                data=[];
                data = reArr.slice(0);

                layui.each(data,function (i,t) {
                    tabledatas.splice(i+1, 0, t);
                })
            }
            parent.layui.table.cache['flowsTable']=tabledatas;
            parent.layui.table.reload('flowsTable',{data:tabledatas});
            parent.layer.close(index);
        });

        $('#btn_canel').on('click',function () {
            parent.layer.close(index);
        });
    })
</script>
</html>